package com.cxs.utils;

import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths;

/*
 * @Author:cxs
 * @Date:2021/10/8  18:27
 * @Version 1.0
 * @Motto:放下杂念,只为迎接明天更好的自己
 * */
public class MarkdownUtil {
    public static void main(String[] args) throws MalformedURLException {
        //输出Markdown到文件
        Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
                .withMarkupLanguage(MarkupLanguage.MARKDOWN)  //格式可选txt，md
                .withOutputLanguage(Language.ZH)  //语言
                .withPathsGroupedBy(GroupBy.TAGS)
                .withGeneratedExamples()
                .withoutInlineSchema()
                .build();
        Swagger2MarkupConverter.from(new URL("http://localhost:8080/bookManagerSys/v2/api-docs"))
                .withConfig(config)
                .build()
                .toFile(Paths.get("bookManagerSys/src/main/resources/docs/markdown"));
    }
}
